package servlet_item;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import factory.ItemManagerFactory;
import pojo.Item;
import service.ItemManager;

public class addServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private ItemManager im = ItemManagerFactory.getItemManagerInstance();
	
	public addServlet() {
		super();
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String contxPath=this.getServletContext().getContextPath();
		req.setCharacterEncoding("UTF-8");
		String itemName=req.getParameter("itemName");
		String place=req.getParameter("place");
		String itemTime=req.getParameter("itemTime");
		String details=req.getParameter("details");
		Boolean down=Boolean.parseBoolean(req.getParameter("down"));
		Item item=new Item(0, itemName, place, itemTime, details, down);
		System.out.println(itemName+""+place+"..."+itemTime+"..."+details+"..."+down);
		im.addItem(item);
	}
}
